package com.qianfeng.openapi.web.master.config;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitConfig {


    @Value("${rabbit.customerExchangeName}")
    private String customerExchangeName;

    @Value("${rabbit.customerQueueName}")
    private String customerQueueName;

    @Value("${rabbit.customerRoutingKey}")
    private String customerRoutingKey;

    @Bean
    public TopicExchange customerExchange(){
        return (TopicExchange) ExchangeBuilder.topicExchange(customerExchangeName).build();
    }

    @Bean
    public Queue customerQueue(){
        return QueueBuilder.durable(customerQueueName).build();
    }


    @Bean
    public Binding customerBinding(Queue customerQueue,TopicExchange customerExchange){
        return BindingBuilder.bind(customerQueue).to(customerExchange).with(customerRoutingKey);
    }


}
